const jwt = require('jsonwebtoken');
const { expressjwt } = require('express-jwt');
const miyao = 'iloveu';

//返回token生成函数
function gettoken(payload, expiresIn) {
    return jwt.sign(payload, miyao, {
        expiresIn: expiresIn
    });
}

function verifytoken() {
    return expressjwt({ secret: miyao, algorithms: ['HS256'] });
}

module.exports = { gettoken, verifytoken };